﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Shapes;
using System.Drawing;
using System.Windows.Controls;
using System.ComponentModel;

namespace PewPew
{
    public class TargetType
    {
        public string inputText;
        public System.Windows.Media.SolidColorBrush color;
    }

    public class Target
    {
        
        public enum TargetName {Action1,Action2,Action3,Action4};
        public static Dictionary<TargetName, TargetType> EnemyTypes = new Dictionary<TargetName, TargetType>()
        { 
            { TargetName.Action1, new TargetType { inputText = "Action1", color = System.Windows.Media.Brushes.ForestGreen } },
            { TargetName.Action2, new TargetType { inputText = "Action2", color = System.Windows.Media.Brushes.Yellow } },
            { TargetName.Action3, new TargetType { inputText = "Action3", color = System.Windows.Media.Brushes.Purple } },
            { TargetName.Action4, new TargetType { inputText = "Action4", color = System.Windows.Media.Brushes.Teal } }
        };

        double radius;
        private Point ctr;
        Random randAction = new Random();

        TargetType type;

        public Target(Point ctr, Label enemyLabel, double sizeFactor)
        {
            int currAction = randAction.Next(0, Enum.GetNames(typeof(TargetName)).Length);
            this.radius = (0.1 * sizeFactor);
            this.ctr = ctr;
            this.type = Target.EnemyTypes[(TargetName)currAction];

            enemyLabel.Content = "enemy: " + this.type.inputText;
        }
        
        public bool ContainsPoint(Point toTest)
        {
            // Is the point inside the circle? Sum the squares of the x-difference and
            // y-difference from the centre, square-root it, and compare with the radius.
            // (This is Pythagoras' theorem.)

            int dX = Math.Abs(toTest.X - ctr.X);
            int dY = Math.Abs(toTest.Y - ctr.Y);

            int sumOfSquares = dX * dX + dY * dY;

            int distance = (int) Math.Sqrt(sumOfSquares);

            return (radius >= distance);
            
        }

        public System.Windows.Media.SolidColorBrush getColor()
        {
            return this.type.color ;
        }
        public int getX() 
        {
            return ctr.X;
        }

        public int getY()
        {
            return ctr.Y;
        }

        public double getRadius()
        {
            return this.radius;
        }

        public String getName()
        {
            return this.type.inputText;
        }

        public static TargetType EnemyTypeByInputText(String inputText) {
            return EnemyTypes.FirstOrDefault(type => type.Value.inputText == inputText).Value;
        }
   

    }
}
